﻿package Framework.MQ
{

    public class MessageManager extends Object
    {
        private var _object:Object;
        private static var _instance:MessageManager = new MessageManager;

        public function MessageManager()
        {
            this._object = new Object();
            return;
        }// end function

        public function regist(param1:IMessageBase) : void
        {
            this._object[param1.getType()] = param1;
            return;
        }// end function

        public function unRegist(param1:int) : void
        {
            if (this._object[param1] == undefined)
            {
                return;
            }
            delete this._object[param1];
            return;
        }// end function

        public function findMessage(param1:int) : IMessageBase
        {
            if (this._object[param1] == undefined)
            {
                return null;
            }
            return this._object[param1];
        }// end function

        public function createMessage(param1:int) : IMessageBase
        {
            if (this._object[param1] == undefined)
            {
                return null;
            }
            return this._object[param1].clone();
        }// end function

        public static function instance() : MessageManager
        {
            return _instance;
        }// end function

    }
}
